package com.example;

import java.util.HashMap;
import java.util.Map;

import com.example.interpreter.AlertRuleInterpreter;
import com.example.interpreter2.Context;
import com.example.interpreter2.ExpressionNode;

/**
 * Hello world!
 *
 */
public class App 
{
    public static void main( String[] args )
    {
        // alertRuleDemo();
        loopDemo();
    }

    public static void alertRuleDemo() {
        AlertRuleInterpreter interpreter = new AlertRuleInterpreter("key1 > 10 && key2 > 100 || key3>300");
        Map<String, Integer> stat = new HashMap<>();
        stat.put("key1", 11);
        stat.put("key2", 111);
        stat.put("key3", 111);
        boolean ret = interpreter.interpret(stat);
        System.out.println("ret = " + ret);
    }

    public static void loopDemo() {

        String input = "LOOP 2 PRINT 你好 BREAK END PRINT 你好 SPACE 世界 世界 BREAK";
        Context context = new Context(input);

        ExpressionNode node = new ExpressionNode();
        node.interpret(context);
        node.execute();

    }
}
